package cn.jetpiece.cloud.joss.api.object;

import cn.jetpiece.cloud.joss.api.object.model.params.GetObject;
import cn.jetpiece.cloud.joss.api.object.model.params.JossPostObject;
import cn.jetpiece.cloud.joss.api.object.model.params.JossPutObject;
import cn.jetpiece.cloud.joss.api.object.model.result.JossPartEtag;
import cn.jetpiece.cloud.joss.api.object.model.result.UploadObjectResult;
import cn.jetpiece.cloud.model.response.Result;
import cn.jetpiece.cloud.resource.annotation.annotation.ApiResource;
import cn.jetpiece.cloud.resource.annotation.annotation.ScanResource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 对象接口
 *
 * @author XuJZ
 * @since 2020-09-05 15:41:52
 */
@Api(tags = "对象存储")
@ApiResource(name = "对象存储")
public interface JossObjectApi {

    String API = "/joss";

    /**
     * 上传对象
     *
     * @param params 请求信息
     * @param etag 分片合并参数,分片标记
     * @return 对象信息
     */
    @ApiOperation(value = "文件上传")
    @ScanResource(name = "文件上传", path = API + "/**", method = RequestMethod.POST)
    Result<UploadObjectResult> postObject(JossPostObject params, @RequestParam(value = "file", required = false) MultipartFile file, @RequestBody(required = false) List<JossPartEtag> etag);

    /**
     * 上传对象
     *
     * @param params 请求信息
     * @return 对象信息
     */
    @ApiOperation(value = "文件上传")
    @ScanResource(name = "文件上传", path = API + "/**", method = RequestMethod.PUT)
    Result<UploadObjectResult> putObject(JossPutObject params, @RequestParam(value = "file", required = false) MultipartFile file);

    /**
     * 获取对象
     *
     * @param params 请求信息
     */
    @ApiOperation(value = "获取对象")
    @ScanResource(name = "获取对象", path = API + "/**", method = RequestMethod.GET, requiredLogin = false)
    void getObject(@SpringQueryMap GetObject params);

    /**
     * 删除对象
     */
    @ApiOperation(value = "删除对象")
    @ScanResource(name = "删除对象", path = API + "/**", method = RequestMethod.DELETE)
    Result<String> deleteObject();
}
